home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performFlow.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  12.7 KB  |  480 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Dec. 4/96
  22. //
  23. //  Description:
  24. //      Option box dialog for 'flow' command
  25. //
  26.  
  27.  
  28. //
  29. //  Procedure Name:
  30. //      setOptionVars
  31. //
  32. //  Description:
  33. //        Initialize the option values.
  34. //
  35. //  Input Arguments:
  36. //        Whether to set the options to default values.
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41. proc setOptionVars (int $forceFactorySettings)
  42. {
  43.     if ($forceFactorySettings || !`optionVar -exists flowDivisionsFront`) {
  44.         optionVar -intValue flowDivisionsFront 5;
  45.     }
  46.     if ($forceFactorySettings || !`optionVar -exists flowDivisionsUp`) {
  47.         optionVar -intValue flowDivisionsUp 2;
  48.     }
  49.     if ($forceFactorySettings || !`optionVar -exists flowDivisionsSide`) {
  50.         optionVar -intValue flowDivisionsSide 2;
  51.     }
  52.     if ($forceFactorySettings || !`optionVar -exists flowAroundObject`) {
  53.         optionVar -intValue flowAroundObject 1;
  54.     }
  55.     if ($forceFactorySettings || !`optionVar -exists flowLocalEffect`) {
  56.         optionVar -intValue flowLocalEffect 0;
  57.     }
  58.     if ($forceFactorySettings || !`optionVar -exists flowLocalEffectFront`) {
  59.         optionVar -intValue flowLocalEffectFront 2;
  60.     }
  61.     if ($forceFactorySettings || !`optionVar -exists flowLocalEffectUp`) {
  62.         optionVar -intValue flowLocalEffectUp 2;
  63.     }
  64.     if ($forceFactorySettings || !`optionVar -exists flowLocalEffectSide`) {
  65.         optionVar -intValue flowLocalEffectSide 2;
  66.     }
  67. }
  68.  
  69. //
  70. //  Procedure Name:
  71. //      flowEnabling
  72. //
  73. //  Description:
  74. //        Enable/disable the local effect widgets
  75. //
  76. //  Input Arguments:
  77. //      parent - Top level parent layout of the option box UI.  Required so
  78. //               that UI object names can be successfully resolved.
  79. //
  80. //        state   - Whether to enable or to disable the controls
  81. //
  82. //  Return Value:
  83. //      None.
  84. //
  85. global proc flowEnabling(string $parent, int $state)
  86. {
  87.     setParent $parent;
  88.  
  89.     intFieldGrp -edit -enable $state effectFront;
  90.     intFieldGrp -edit -enable $state effectUp;
  91.     intFieldGrp -edit -enable $state effectSide;
  92. }
  93.  
  94. //
  95. //  Procedure Name:
  96. //      flowTickBoxControl
  97. //
  98. //  Description:
  99. //        If the flow is object centered, then by default we want global
  100. //        effect of the lattice on the object.
  101. //        If the flow is curve centered, then by default we want local effect
  102. //        of the lattice around the portion of the curve where the object is.
  103. //
  104. //        The user can change these defaults, but this just forces the
  105. //        "Local Effect" checkbox to a reasonable default when
  106. //        the "Lattice Around" option is changed between Object and Curve.
  107. //
  108. //  Input Arguments:
  109. //      parent - Top level parent layout of the option box UI.  Required so
  110. //               that UI object names can be successfully resolved.
  111. //
  112. //  Return Value:
  113. //      None.
  114. //
  115. global proc flowTickBoxControl(string $parent)
  116. {
  117.     setParent $parent;
  118.  
  119.     if (1 == `radioButtonGrp -query -select object`) {
  120.         checkBoxGrp -edit -value1 false local;
  121.         flowEnabling($parent, false);
  122.     }
  123.     else {
  124.         checkBoxGrp -edit -value1 true local;
  125.         flowEnabling($parent, true);
  126.     }
  127. }
  128.  
  129. //
  130. //  Procedure Name:
  131. //      flowSetup
  132. //
  133. //  Description:
  134. //        Update the state of the option box UI to reflect the option values.
  135. //
  136. //  Input Arguments:
  137. //      parent               - Top level parent layout of the option box UI.
  138. //                             Required so that UI object names can be 
  139. //                             successfully resolved.
  140. //
  141. //        forceFactorySettings - Whether the option values should be set to
  142. //                             default values.
  143. //
  144. //  Return Value:
  145. //      None.
  146. //
  147. global proc flowSetup (string $parent, int $forceFactorySettings)
  148. {
  149.     // Retrieve the option settings
  150.     //
  151.     setOptionVars ($forceFactorySettings);
  152.  
  153.     setParent $parent;
  154.  
  155.     // Query the optionVar's and set the values into the controls
  156.  
  157.     intFieldGrp -edit
  158.         -value1 `optionVar -q flowDivisionsFront`
  159.         divisionsFront;
  160.     intFieldGrp -edit
  161.         -value1 `optionVar -q flowDivisionsUp`
  162.         divisionsUp;
  163.     intFieldGrp -edit
  164.         -value1 `optionVar -q flowDivisionsSide`
  165.         divisionsSide;
  166.  
  167.     if (1 == `optionVar -q flowAroundObject`)
  168.         radioButtonGrp -edit -select 1 object;
  169.     else
  170.         radioButtonGrp -edit -select 2 object;
  171.  
  172.     int $useLocalEffect = `optionVar -q flowLocalEffect`;
  173.     checkBoxGrp -edit -value1 $useLocalEffect local;
  174.  
  175.     intFieldGrp -edit
  176.         -value1 `optionVar -q flowLocalEffectFront`
  177.         effectFront;
  178.     intFieldGrp -edit
  179.         -value1 `optionVar -q flowLocalEffectUp`
  180.         effectUp;
  181.     intFieldGrp -edit
  182.         -value1 `optionVar -q flowLocalEffectSide`
  183.         effectSide;
  184.  
  185.     flowEnabling $parent $useLocalEffect;
  186. }
  187.  
  188. //
  189. //  Procedure Name:
  190. //      flowCallback
  191. //
  192. //  Description:
  193. //        Update the option values with the current state of the option box UI.
  194. //
  195. //  Input Arguments:
  196. //      parent - Top level parent layout of the option box UI.  Required so
  197. //               that UI object names can be successfully resolved.
  198. //
  199. //        doIt   - Whether the command should execute.
  200. //
  201. //  Return Value:
  202. //      None.
  203. //
  204. global proc flowCallback (string $parent, int $doIt)
  205. {
  206.     setParent $parent;
  207.  
  208.     // Set the optionVar's from the control values, and
  209.     // then perform the command
  210.  
  211.     optionVar -intValue flowDivisionsFront
  212.         `intFieldGrp -query -value1 divisionsFront`;
  213.     optionVar -intValue flowDivisionsUp
  214.         `intFieldGrp -query -value1 divisionsUp`;
  215.     optionVar -intValue flowDivisionsSide
  216.         `intFieldGrp -query -value1 divisionsSide`;
  217.  
  218.     if (1 == `radioButtonGrp -query -select object`)
  219.         optionVar -intValue flowAroundObject 1;
  220.     else
  221.         optionVar -intValue flowAroundObject 0;
  222.  
  223.     optionVar -intValue flowLocalEffect
  224.         `checkBoxGrp -query -value1 local`;
  225.  
  226.     optionVar -intValue flowLocalEffectFront
  227.         `intFieldGrp -query -value1 effectFront`;
  228.     optionVar -intValue flowLocalEffectUp
  229.         `intFieldGrp -query -value1 effectUp`;
  230.     optionVar -intValue flowLocalEffectSide
  231.         `intFieldGrp -query -value1 effectSide`;
  232.                     
  233.     if ($doIt) {
  234.         performFlow false; 
  235.         addToRecentCommandQueue "performFlow false" "Flow";
  236.     }
  237. }
  238.  
  239. //
  240. //  Procedure Name:
  241. //      flowOptions
  242. //
  243. //  Description:
  244. //        Construct the option box UI.  Involves accessing the standard option
  245. //        box and customizing the UI accordingly.
  246. //
  247. //  Input Arguments:
  248. //      None.
  249. //
  250. //  Return Value:
  251. //      None.
  252. //
  253. proc flowOptions ()
  254. {
  255.     string $commandName = "flow";
  256.  
  257.     //    Build the option box actions.
  258.     //
  259.     string $callback = ($commandName + "Callback");
  260.     string $setup = ($commandName + "Setup");
  261.  
  262.     //    STEP 1:  Get the option box.
  263.     //    ============================
  264.     //
  265.     //  The value returned is the name of the layout to be used as
  266.     //    the parent for the option box UI.
  267.     //
  268.     string $layout = getOptionBox();
  269.     setParent $layout;
  270.  
  271.     //    STEP 2:  Activate the default UI template.
  272.     //    ==========================================
  273.     //
  274.     //    Activate the default UI template so that the layout of this 
  275.     //    option box is consistent with the layout of the rest of the 
  276.     //    application.
  277.     //
  278.     setUITemplate -pushTemplate DefaultTemplate;
  279.  
  280.     //    STEP 3: Create option box contents.
  281.     //    ===================================
  282.     //
  283.  
  284.     //    Turn on the wait cursor.
  285.     //
  286.     waitCursor -state 1;
  287.  
  288.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  289.     //    option box window is ever resized such that it's entire 
  290.     //    contents is not visible then the scroll bars provided by the
  291.     //    scroll layout will allow the user to access the hidden UI.
  292.     //
  293.     tabLayout -scr true -tv false;
  294.  
  295.     string $parent = `columnLayout -adjustableColumn 1`;
  296.  
  297.     intFieldGrp -numberOfFields 1 -l "Divisions: Front" divisionsFront;
  298.     intFieldGrp -numberOfFields 1 -l "Up" divisionsUp;
  299.     intFieldGrp -numberOfFields 1 -l "Side" divisionsSide;
  300.  
  301.     radioButtonGrp -nrb 2 -l "Lattice Around"
  302.         -l1 "Object" -l2 "Curve"
  303.         -onCommand ("flowTickBoxControl "+$parent)
  304.         object;
  305.  
  306.     checkBoxGrp -ncb 1  -l1 "Local Effect"
  307.         -onCommand1 ("flowEnabling "+$parent+" #1")
  308.         -offCommand1 ("flowEnabling "+$parent+" #1")
  309.         local;
  310.  
  311.     intFieldGrp -numberOfFields 1 -l "Local Effect: Front" effectFront;
  312.     intFieldGrp -numberOfFields 1 -l "Up" effectUp;
  313.     intFieldGrp -numberOfFields 1 -l "Side" effectSide;
  314.  
  315.     //    Turn off the wait cursor.
  316.     //
  317.     waitCursor -state 0;
  318.     
  319.     //    Step 4: Deactivate the default UI template.
  320.     //  ===========================================
  321.     //
  322.     setUITemplate -popTemplate;
  323.  
  324.     //    Step 5: Customize the buttons.  
  325.     //    ==============================
  326.     //
  327.     //    Provide more descriptive labels for the buttons.  This is not 
  328.     //    necessary, but in some cases, for example, a button labelled 
  329.     //    'Create' may be more meaningful to the user than one labelled
  330.     //    'Apply'.
  331.     //
  332.     //  Disable those buttons that are not applicable to the option box.
  333.     //
  334.     //    Attach actions to those buttons that are applicable to the option
  335.     //    box.  Note that the 'Close' button has a default action attached 
  336.     //    to it that will hide the window.  If a a custom action is
  337.     //    attached to the 'Close' button then be sure to call the 'hide the
  338.     //    option box' procedure within the custom action so that the option
  339.     //    box is hidden properly.
  340.  
  341.     //    'Apply' button.
  342.     //
  343.     string $applyBtn = getOptionBoxApplyBtn();
  344.     button -edit
  345.         -command ($callback + " " + $parent + " " + 1)
  346.         -label "Flow"
  347.         $applyBtn;
  348.  
  349.     //    'Save' button.
  350.     //
  351.     string $saveBtn = getOptionBoxSaveBtn();
  352.     button -edit 
  353.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  354.         $saveBtn;
  355.  
  356.     //    'Reset' button.
  357.     //
  358.     string $resetBtn = getOptionBoxResetBtn();
  359.     button -edit 
  360.         -command ($setup + " " + $parent + " " + 1)
  361.         $resetBtn;
  362.  
  363.     //    Step 6: Set the option box title.
  364.     //    =================================
  365.     //
  366.     setOptionBoxTitle("Flow Path Object Options");
  367.  
  368.     //    Step 7: Customize the 'Help' menu item text.
  369.     //    ============================================
  370.     //
  371.     setOptionBoxHelpTag( "FlowPathObject" );
  372.  
  373.     //    Step 8: Set the current values of the option box.
  374.     //    =================================================
  375.     //
  376.     eval (($setup + " " + $parent + " " + 0));    
  377.     
  378.     //    Step 9: Show the option box.
  379.     //    =================================
  380.     //
  381.     showOptionBox();
  382. }
  383.  
  384.  
  385. //
  386. //  Procedure Name:
  387. //      assembleCmd
  388. //
  389. //  Description:
  390. //        Construct the command that will apply the option box values.
  391. //
  392. //  Input Arguments:
  393. //      None.
  394. //
  395. //  Return Value:
  396. //      None.
  397. //
  398. proc string assembleCmd()
  399. {
  400.     string $cmd = "";
  401.     setOptionVars(false);
  402.  
  403.     $cmd = "flowObjects "
  404.            + `optionVar -query flowDivisionsFront` + " "
  405.            + `optionVar -query flowDivisionsUp` + " "
  406.            + `optionVar -query flowDivisionsSide` + " "
  407.            + `optionVar -query flowAroundObject` + " "
  408.            + `optionVar -query flowLocalEffect` + " "
  409.            + `optionVar -query flowLocalEffectFront` + " "
  410.            + `optionVar -query flowLocalEffectUp` + " "
  411.            + `optionVar -query flowLocalEffectSide`;
  412.  
  413.     return $cmd;
  414. }
  415.  
  416. //
  417. //  Procedure Name:
  418. //      performFlow
  419. //
  420. //  Description:
  421. //        Perform the flow command using the corresponding 
  422. //        option values.  This procedure will also show the option box
  423. //        window if necessary as well as construct the command string
  424. //        that will invoke the flow command with the current
  425. //        option box values.
  426. //
  427. //  Input Arguments:
  428. //      0 - Execute the command.
  429. //      1 - Show the option box dialog.
  430. //      2 - Return the command.
  431. //
  432. //  Return Value:
  433. //      None.
  434. //
  435. global proc string performFlow (int $action)
  436. {
  437.     string $cmd = "";
  438.  
  439.     switch ($action) {
  440.  
  441.         //    Execute the command.
  442.         //
  443.         case 0:
  444.             //    Retrieve the option settings
  445.             //
  446.             setOptionVars(false);
  447.  
  448.             //    Get the command.
  449.             //
  450.             $cmd = `assembleCmd`;
  451.  
  452.             //    Execute the command with the option settings.
  453.             //
  454.             eval($cmd);
  455.  
  456.             break;
  457.  
  458.         //    Show the option box.
  459.         //
  460.         case 1:
  461.             flowOptions;
  462.             break;
  463.  
  464.         //    Return the command string.
  465.         //
  466.         case 2:
  467.             //    Retrieve the option settings.
  468.             //
  469.             setOptionVars (false);
  470.  
  471.             //    Get the command.
  472.             //
  473.             $cmd = `assembleCmd`;
  474.             break;
  475.     }
  476.     return $cmd;
  477. }
  478.  
  479.  
  480.